﻿using EMoney.IStock.Client.Framework;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using ThinkDev.Logging;
using ThinkDev.Task;

namespace EMoney.IStock.Client.WinService
{
    public partial class Service1 : ServiceBase
    {
        Logger log_task = LoggerFactory.GetLogger("TaskLogger");

        public Service1()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            LogManager.DefaultLogger.Debug("ClientIStock Service Start!");
            TaskGlobal.Log.OnDebug += log_task.Debug;
            TaskGlobal.Log.OnInfo += log_task.Info;
            TaskGlobal.Log.OnWarn += log_task.Warn;
            TaskGlobal.Log.OnError += log_task.Error;
            TaskGlobal.InitTask();

            LogManager.DefaultLogger.Debug("ThinkDev.Task.InitTask()");
        }

        protected override void OnStop()
        {
            TaskGlobal.StopAll();
            LogManager.DefaultLogger.Debug("ClientIStock Service Stop!");
        }
    }
}
